<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //冒泡排序
        let string = window.prompt('请输入要排序的数字')
        //arr中的字符串
        let arr = string.split(',')
        //把字符串类型转成数字
        for (let i = 0; i < arr.length; i++) {
            arr[i] = Number(arr[i])
        }
        let temp;
        // 排几次
        for (let i = 0; i < arr.length; i++) {
            // 每一次怎么排
            for (let j = 0; j < arr.length-i-1; j++) {
                if (arr[j] > arr[j+1]){
                    temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        document.write(arr)
        document.write("<br/>")
        for (let i = 0; i < arr.length; i++) {
            document.write(arr[i])
        }
    </script>
</head>
<body>

</body>
</html>